package com.xunk.common.core.enums;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @ProjectName: xunk
 * @Package: com.xunk.common.core.enums
 * @ClassName: DeviceEnum
 * @Author: yangwendong
 * @Description:
 * @Date: 2021/4/1 13:53
 * @Version: 1.0
 */
public enum DeviceEnum {

    SMOKE_SENSOR("烟雾报警器", "smoke-sensor"),
    WATER_SENSOR("水浸报警器", "water-sensor"),
    GAS_SENSOR("燃气报警器", "gas-sensor"),
    DOOR_WINDOW_SENSOR("门窗传感器", "door-window-sensor"),
    GATEWAY("中控屏", "gateway"),
    /**
     * 窗帘
     */
    WINDOW_CURTAIN("窗帘", "window-curtain"),
    TWO_KEY_WINDOW_CURTAIN("双开关窗帘", "two-key-window-curtain"),
    THREE_KEY_WINDOW_CURTAIN("三开关窗帘", "three-key-window-curtain"),
    /**
     * 智能灯泡/灯带
     */
    LIGHTBULB("智能驱动LED灯带版", "lightbulb"),
    ONE_KEY_SWITCH("单键开关", "one-key-switch"),
    TWO_KEY_SWITCH("双键开关", "two-key-switch"),
    THREE_KEY_SWITCH("三键开关", "three-key-switch"),
    AIR_CONDITIONER("中央空调智能控制网关", "air-conditioner"),
    FRESH_AIR("新风机", "fresh-air"),
    WATER_METER("水表", "water-meter"),
    HEAT_METER("热量表", "heat-meter"),
    LIGHT("灯光", "light"),
    AIR_SWITCH("空气盒子", "airSwitch"),

    WATER_HEATER("热水器", "water-heater"),
    UNKNOWN("未知设备", "Unknown");

    private String deviceName;
    private String deviceType;

    DeviceEnum(String deviceName, String deviceType) {
        this.deviceName = deviceName;
        this.deviceType = deviceType;
    }

    private static final Map<String, DeviceEnum> DEVICE_TYPE_ENUM_MAP = Arrays.stream(DeviceEnum.values()).collect(Collectors.toMap(DeviceEnum::getDeviceType, Function.identity(), (a, b) -> a));

    public static DeviceEnum parseDeviceEnum(String deviceType) {
        return DEVICE_TYPE_ENUM_MAP.getOrDefault(deviceType, UNKNOWN);
    }

    public String getDeviceName() {
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public String getDeviceType() {
        return deviceType;
    }

    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }
}
